import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { GoodsService } from '../service/goods.service';
import { CreateGoodsDto } from '../dto/goods/create-goods.dto';
import { UpdateGoodsDto } from '../dto/goods/update-goods.dto';
import { ListGoodsDto } from '../dto/goods/list-goods.dto';

@Controller('grocery/goods')
export class GoodsController {
  constructor(private readonly goodsService: GoodsService) {}

  @Post('insert')
  create(@Body() createGoodsDto: CreateGoodsDto) {
    return this.goodsService.create(createGoodsDto);
  }

  @Post('list')
  findAll(@Body() listGoodsDto: ListGoodsDto) {
    return this.goodsService.findAll(listGoodsDto);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.goodsService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateGoodsDto: UpdateGoodsDto) {
    return this.goodsService.update(+id, updateGoodsDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.goodsService.remove(+id);
  }
}
